In [1]:
import pandas as pd
import matplotlib.pyplot as plt
import plotly.graph_objects as go
from sklearn.datasets import load_iris
In [2]:
pip install -U kaleido
Requirement already satisfied: kaleido in c:\users\raman\anaconda3\lib\site-packages (0.2.1)
Note: you may need to restart the kernel to use updated packages.
[notice] A new release of pip is available: 23.1 -> 23.1.2
[notice] To update, run: python.exe -m pip install --upgrade pip

Load Iris dataset¶

In [3]:
iris = load_iris()
df = pd.DataFrame(data=iris.data, columns=iris.feature_names)

Matplotlib Graph¶

In [4]:
plt.figure(figsize=(8, 5))
plt.plot(df['sepal length (cm)'], label='sepal length')
plt.plot(df['sepal width (cm)'], label='sepal width')
plt.xlabel('Sample')
plt.ylabel('Measurement (cm)')
plt.title('Iris Dataset - Sepal Measurements')
plt.legend()
plt.savefig('matplotlib_graph.png')

Plotly Graph¶

In [5]:
fig = go.Figure()
fig.add_trace(go.Scatter(x=df.index, y=df['sepal length (cm)'], name='sepal length'))
fig.update_layout(title='Iris Dataset - Sepal Measurements', xaxis_title='Sample', yaxis_title='Measurement (cm)')

Iris Dataset¶

The Iris dataset is a classic and widely-used dataset in machine learning and statistics. It contains measurements of various attributes of three different species of Iris flowers: setosa, versicolor, and virginica.

The dataset consists of the following features:

Sepal Length (cm) Sepal Width (cm) Petal Length (cm) Petal Width (cm)

Colored Markdown text using HTML tags The MSE equation can be used to evaluate the performance of a machine learning model trained on the Iris dataset. It measures the average squared difference between the predicted values and the true values allowing for the comparison of different models and variations.

Save the image of the first flower in the dataset¶

In [6]:
image_path = 'iris_flower.png'
plt.figure(figsize=(2, 2))
plt.imshow(plt.imread(image_path), cmap='gray')
plt.axis('off')
plt.savefig(image_path)
plt.show()
In [ ]: